import {NextRequest, NextResponse} from "next/server";
import {prisma} from "@/lib/db";

export async function POST(req: NextRequest) {
    const body = await req.json()
    const name = body.name
    // const stuName = body.stuName
    // if (!name || !stuName)
    if (!name)
        return NextResponse.json({"msg": "error!"}, {
            status: 500
        })

    try {
        const exist_resume = await prisma.resume.findFirst({
            where: {
                AND: [
                    {name: name},
                    // {stuName: stuName}
                ]
            }
        })
        if (exist_resume) return NextResponse.json({"msg": "数据已存在!"}, {
            status: 500
        })

        const resume = await prisma.resume.create({
            data: {
                // name, stuName
                name
            }
        })
        console.log(resume)
        return NextResponse.json({resume})
    } catch (err) {
        console.log(err)
        return NextResponse.json({"msg": "error!"}, {
            status: 500
        })
    }

}